//
//  YMPresentationController.swift
//  WB
//
//  Created by leador on 17/3/20.
//  Copyright © 2017年 袁满. All rights reserved.
//

import UIKit

class YMPresentationController: UIPresentationController {
    
    var presentedFrame:CGRect = CGRect.zero
    
    lazy var coverView = UIView()
    
    override func containerViewWillLayoutSubviews() {
        
        super.containerViewWillLayoutSubviews()
        
        presentedView?.frame = presentedFrame
        
        coverView.backgroundColor = UIColor(white:0,alpha: 0.2)
        coverView.frame = containerView!.bounds
        containerView?.insertSubview(coverView, at:0)
        
        let tap = UITapGestureRecognizer(target: self, action:#selector(YMPresentationController.coverClick))
        coverView.addGestureRecognizer(tap)
    }

}

//MARK: ---事件监听---
extension YMPresentationController {
    
    func coverClick() {
        
        presentedViewController.dismiss(animated: true, completion: nil)
        
    }
}
